package cn.merryyou.jpa.test;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import java.io.Serializable;
import java.util.Set;

@Getter
@Setter
@Entity
@NoArgsConstructor
public class Course implements Serializable {
    private static final long serialVersionUID = -728907731616357211L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private int id;
    private String name;

    public Course(String name) {
        this.name = name;
    }

    @OneToMany(mappedBy="course",cascade= CascadeType.ALL)
    private Set<CourseTeacher> teachers;

    @OneToMany(mappedBy="course",cascade= CascadeType.ALL)
    private Set<CourseStudent> students;


}